#coding: utf-8
class CulturalHeritage::CareAndMaintenance < ActiveRecord::Base

  default_scope where("cultural_heritage_care_and_maintenances.deleted = 0")
  belongs_to :obj_care_and_maintenance_type, :class_name => 'CulturalHeritage::CareAndMaintenanceType',  :foreign_key => 'care_and_maintenance_type'
  belongs_to :obj_cultural_institution, :class_name => 'CulturalHeritage::CulturalInstitution',  :foreign_key => 'cultural_institution'
  belongs_to :obj_cultural_heritage, :class_name => 'CulturalHeritage::CulturalHeritage',  :foreign_key => 'cultural_heritage'
  belongs_to :obj_care_and_maintenance_type, :class_name => 'CulturalHeritage::CareAndMaintenanceType', :foreign_key => 'care_and_maintenance_type'
  belongs_to :obj_security_people, :class_name => 'Security::Person', :foreign_key => 'security_person'
  belongs_to :obj_care_and_maintenance_supervisor, :class_name => 'Security::Person', :foreign_key => 'supervisor'

  validates :cultural_institution, :presence => {:message => "La Institución Cultural es requerida"}
  validates :cultural_heritage, :presence => {:message => "El Patrimonio Cultural es requerido"}
  validates :care_and_maintenance_type, :presence => {:message => "El Tipo de Cuidado y Mantenimiento es requerido"}
  validates :start_date, :presence => {:message => "La fecha de inicio es requerida"}
  validates :end_date, :presence => {:message => "La fecha final es requerida"}
#  validates :supervisor, :presence => {:message => "supervisor es requerido"}
#  validates :mayor, :presence => {:message => "La magnitud es requerida"}

#  default_scope where("mayor = 0")
#  default_scope where("status = 0")

    def str_care_and_maintenance_type
    if care_and_maintenance_type == 0
      return "Registrado"
    end
    if care_and_maintenance_type == 1
      return "Atendido"
    end
  end

  def str_person_type
    if person_type == 0
      return "Natural"
    end
    if person_type == 1
      return "Jurídico"
    end
  end

  def str_mayor
    if mayor == 0
      return "Por Evaluar"
    end
    if mayor == 0
      return "Menor"
    end
    if mayor == 1
      return "Mayor"
    end
  end

  def str_proceed
    if status == 0
      return "No Procede"
    end
    if status == 1
      return "Procede"
    end
  end
end
